<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<title>销售报价新增</title>
		<link rel="stylesheet" type="text/css" href="css/public.css">
		<script language="JavaScript" src="js/public.js"></script>
		<script type="text/javascript" src="js/date1.js"></script>
		<script type="text/javascript" src="js/sellprice.js"></script>
		<script type="text/javascript" src="js/validate.js"></script>
		<script type="text/javascript" src="js/ajax.js"></script>	
		<script type="text/javascript">
			function validate(){
				//客户
				var customerName = document.getElementById('customerName');
				//订单编号
				var sellPriceCode = document.getElementById('sellPriceCode');
				//币别名称
				var currencyName = document.getElementById('currencyName');
				//制单人
				var makeBiller = document.getElementById('makeBiller');
				//主管
				var managerName = document.getElementById('managerName');
				//部门名称
				var departmentName = document.getElementById('departmentName');
				//业务员名称
				var businesserName = document.getElementById('businesserName');
				//表格
				var mbody = document.getElementById('mbody');
				
				//验证供应商名称
				if(!isNotNull(customerName,'客户'))
					return false ;	
				//编号
				if(!isNotNull(sellPriceCode,'编号'))
					return false ;
				//验证币别名称
				if(!isNotNull(currencyName,'币别'))
					return false ;	
				//主管
				if(!isNotNull(managerName,'主管'))
					return false ;	
				//部门
				if(!isNotNull(departmentName,'部门'))
					return false ;	
				//业务员
				if(!isNotNull(businesserName,'业务员'))
					return false ;	
				//制单人
				if(!isNotNull(makeBiller,'制单人'))
					return false ;	

				if(mbody.rows.length<=0){
					alert("请添加明细");
					return false;			
				}
				else{
					for(var i=0;i<mbody.rows.length;i++){
						//代码
						var materialCode = document.getElementById('materialCode'+i);
						//数量
						var measureUnitName = document.getElementById('measureUnitName'+i);
						//税率
						var taxRate = document.getElementById('taxRate'+rowIndex);
						
						var rowIndex = i+1 ;
						//验证代码					
						if(!(isNotNull(materialCode,'第'+rowIndex+'行:'+'物料代码')&&f_check_ZhOrNumOrLett(materialCode,'第'+rowIndex+'行:'+'物料代码')))
							return false;
						//单位
						if(!(isNotNull(measureUnitName,'第'+rowIndex+'行:'+'单位')&&f_check_ZhOrNumOrLett(measureUnitName,'第'+rowIndex+'行:'+'单位')))
							return false;
						//稅率
						if(!(isNotNull(taxRate,'第'+rowIndex+'行:'+'稅率')&&f_check_float(taxRate,'第'+rowIndex+'行:'+'稅率')))
							return false;
					}				
				}
			}
		function showList() {
		window.location.href("showSellPriceList.action");
	}
		</script>		
		
	</head>
<body>
	<div id="info_all">
		<div id="info_top"> 
			销售报价新增 
		</div>
		<!-- 主输入区 -->
		<!-- 功能按钮 -->
		<s:form action="addSellPrice.action" method="post" theme="simple" cssClass="submitForm" onsubmit=" return validate()">
		<div id="info_main">
			<!-- 查询栏 -->
			<div id="info_input">
				<hr>
				<table>
					<tr>
						<td width="60px">
							购货单位*
						</td>
						<td width="130px">	
							<s:hidden name="sellPrice.customerId" id="customerId"></s:hidden>
							<s:textfield  size="12" name="customerName" id="customerName"></s:textfield>
							<img src="images/kookup.gif" style="cursor:hand" onclick="openWin('selectCustomer.action','supplier',750,700,0)">
						</td>
						<td width="50px">
							日期*
						</td>
						<td width="130px">
							<s:textfield name="sellPrice.sellDate" id='sellDate' size="12"  cssStyle="cursor:hand" onclick="calendar.setHook(this)"></s:textfield>
							
						</td>
						<td width="55px">
							编号*
						</td>
						<td width="130px">
							<s:textfield name="sellPrice.sellPriceCode"  readonly="true" size="12" id="sellPriceCode"></s:textfield>
						</td>
						<td width="55px">
							币别*
						</td>
						<td width="130px">
							<s:hidden name="sellPrice.currencyId" id="currencyId"></s:hidden>
							<s:textfield name="" id="currencyName" size="12"></s:textfield>
							<img src="images/kookup.gif" style="cursor:hand"  onclick="openWin('selectCurrency.action','currency',750,700,0)">
						</td>
					</tr>
					<tr>
						
						<td>
							主管*
						</td>
						<td>
						    <s:hidden id="candiateId"></s:hidden>
							<s:hidden id="candiateName"></s:hidden>
							<s:hidden name="sellPrice.managerId" id="managerId"></s:hidden>
							<s:textfield name="" id="managerName" size="12"></s:textfield>
							<img src="images/kookup.gif" style="cursor:hand"  onclick="multiSelect2('candiateName','candiateId','managerName','managerId','selectMultiCandiate.action','candiate',750,700,0)">
						</td>
					
						<td>
							部门*
						</td>
						<td>
							<s:hidden name="sellPrice.departmentId" id="departmentId"></s:hidden>
							<s:textfield name="" id="departmentName" size="12"></s:textfield>
							<img src="images/kookup.gif" style="cursor:hand"  onclick="openWin('selectDepartment.action','department',500,600,0)">
						</td>
						<td>
							业务员*
						</td>
						<td>
							<s:hidden name="sellPrice.businesserId" id="businesserId"></s:hidden>
							<s:textfield name="" id="businesserName" size="12"></s:textfield>
							<img src="images/kookup.gif" style="cursor:hand"  onclick="multiSelect2('candiateName','candiateId','businesserName','businesserId','selectMultiCandiate.action','candiate',750,700,0)">
						</td>
						<td>
							汇率*
						</td>
						<td>
							<s:textfield name='sellPrice.exchangeRate' id="rate" readonly="true"  size="12" ></s:textfield>
						</td>
					</tr>
					<tr>

						<td>
							制单人*
						</td>
						<td >
							<s:textfield name="sellPrice.makeBiller" id='makeBiller' readonly="true" size="12"></s:textfield>
						</td>
						<td>
							审核人
						</td>
						<td >
							<s:textfield name="sellPrice.checker" id='checker' readonly="true" size="12"></s:textfield>
						</td>
						<td>
							审核日期
						</td>
						<td >
							<s:textfield name="sellPrice.checkDate" id='checkDate'size="12"  readonly="true"></s:textfield>
						</td>
					</tr>
				</table>
				<hr>

			</div>
			<div class="sele" style="text-align: left; padding-left: 10px;">
				<input type="button" value="新增" onClick="addMaterialToSellPrice()"
					onfocus="this.blur()" onMouseOver="this.className='btnover'"
					onmouseout="this.className='btnout'" class="btnsize" />
				<input type="button" value="删除" onClick="delrow()"
					onFocus="this.blur()" onMouseOver="this.className='btnover'"
					onmouseout="this.className='btnout'" class="btnsize" />
				<hr>
			</div>
			<!-- 信息显示栏 -->
			<div id="info_info4">
				<table id="info_table" width="1300px" cellspacing=1px
					cellpadding=1px class="sortable">
					<thead id="head">
						<tr>
							<th width="10px">
								<input type="checkbox" name="checkbox" onClick="selectAll()" />
							</th>
								<th width="100px">
								产品代码*
							</th>
							<th width="90px">
								产品名称
							</th>
							<th width="90px">
								规格型号
							</th>
							<th width="130px">
								基本单位名称
							</th>
							<th width="130px">
								基本单位数量（从）
							</th>
							<th width="130px">
								基本单位数量（到）
							</th>
							<th width="80px">
								单位*
							</th>
							<th width="90px">
								数量段(从)
							</th>
							<th width="90px">
								数量段(到)
							</th>
							<th width="70px">
								单价
							</th>
							<th width="90px">
								含税单价
							</th>
							<th width="70px">
								税率
							</th>
							<th width="80px">
								折扣率
							</th>
							<th width="120px">
								实际含税单价
							</th>
							<th width="70px">
								备注
							</th>
						</tr>
					</thead>
					<tbody id="mbody">
						
					</tbody>
					<tfoot>
						<tr>
						</tr>
					</tfoot>
				</table>
				<script language="javascript">  
						//("表格名称","奇数行背景","偶数行背景","点击后背景");
						 mouseclick("info_table","#ffffff","#ffffff","#e6f0fd");
						 //("表格名称","奇数行背景","偶数行背景");
						 //setcolor("t","#ffffff","#ffffff");
				</script>
			</div>
			<div style="margin: 6px; text-align: center;">
				<input type="submit" value="保存"
					onFocus="this.blur()" onMouseOver="this.className='btnover'"
					onmouseout="this.className='btnout'" class="btnsize" />
				&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" value="返回" onClick="showList()"
				onFocus="this.blur()" onMouseOver="this.className='btnover'"
				onmouseout="this.className='btnout'" class="btnsize" />
			</div>
		</div>
		</s:form>
	</div>
</body>
</html>
							